package com.lagou.edu.mvcframework.pojo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * To inject a {@link Interceptor} to mvc framework, should implement this interface,
 * and mark with the annotation {@link com.lagou.edu.mvcframework.annotations.LagouInterceptor}
 * to make a statement that framework should initialize given interceptor, and add it as interceptor
 * to framework.
 * <p>
 * The interceptor now implements as intercept all handler.
 *
 * @author leonzhangxf
 */
public interface Interceptor {

    /**
     * Intercept target handler
     *
     * @param handler  handler to be intercepted
     * @param args args which use to invoke handler
     * @param request  request
     * @param response response
     * @return true-intercepted success,would go no, false-intercepted judge failed, not go on
     */
    boolean intercept(Handler handler, Object[] args, HttpServletRequest request, HttpServletResponse response);
}
